import { IBaseBehavior } from "../../base/IBaseBehavior";
import { BT_State, BT_Type } from "../../BTDefine";
import { BTFactory } from "../../BTFactory";
import { BaseBehavior } from "../BaseBehavior";

export abstract class Decorator extends BaseBehavior {
    protected _child: IBaseBehavior = null;

    constructor() {
        super();
        this._type = BT_Type.TYPE_DECORATOR;

    }

    setChild(child: IBaseBehavior | string) {
        this._child = BTFactory.getNode(child);
    }

    public getChild(): IBaseBehavior {
        return this._child;
    }

    public abort(): BT_State {
        if (this._child.isRunning()) {
            this._child.abort();
        }

        return super.abort();
    }

    public reset(): void {
        super.reset();
        // this._child = null;
    }

}